/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.myapp.struts;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Rodrigo
 */
@Entity
@Table(name = "VEICULOS")
@NamedQueries({@NamedQuery(name = "Veiculos.findByIdVeiculo", query = "SELECT v FROM Veiculos v WHERE v.idVeiculo = :idVeiculo"), @NamedQuery(name = "Veiculos.findByVagas", query = "SELECT v FROM Veiculos v WHERE v.vagas = :vagas")})
public class Veiculos implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "ID_VEICULO", nullable = false)
    private Integer idVeiculo;
    @Column(name = "VAGAS", nullable = false)
    private int vagas;
    @JoinColumn(name = "CPF_DONO", referencedColumnName = "CPF")
    @ManyToOne
    private PessoaPersistente cpfDono;
    
   
    public Veiculos() {
    }

    public Veiculos(Integer idVeiculo) {
        this.idVeiculo = idVeiculo;
    }

    public Veiculos(Integer idVeiculo, int vagas) {
        this.idVeiculo = idVeiculo;
        this.vagas = vagas;
    }
    

    public Integer getIdVeiculo() {
        return idVeiculo;
    }

    public void setIdVeiculo(Integer idVeiculo) {
        this.idVeiculo = idVeiculo;
    }

    public int getVagas() {
        return vagas;
    }

    public void setVagas(int vagas) {
        this.vagas = vagas;
    }

    public PessoaPersistente getCpfDono() {
        return cpfDono;
    }

    public void setCpfDono(PessoaPersistente cpfDono) {
        this.cpfDono = cpfDono;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idVeiculo != null ? idVeiculo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Veiculos)) {
            return false;
        }
        Veiculos other = (Veiculos) object;
        if ((this.idVeiculo == null && other.idVeiculo != null) || (this.idVeiculo != null && !this.idVeiculo.equals(other.idVeiculo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.myapp.struts.Veiculos[idVeiculo=" + idVeiculo + "]";
    }

}
